package charts;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;
import edu.app.persistence.Recette;
import java.awt.Dimension;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class StatCategorie extends JFrame{
   


    DefaultPieDataset dataset;//Dataset qui va contenir les Données
    JFreeChart graphe;        //Graphe
    ChartPanel cp;            //Panel
    
  public JFreeChart getGraphe()
        {
            return graphe;
        }
    public StatCategorie() throws SQLException {


            
        dataset = new DefaultPieDataset();
//Statique
        dataset.setValue("Desser",new Double(60.0) );
        dataset.setValue("PLat",new Double(20.0) );
        dataset.setValue("autre",new Double(80.0) );
 //*Connexion récupération des données
//        Double d;
//        String ch;
//        try {
//            Connexion.rs = Connexion.st.executeQuery("select * from etudiant");
//            while (Connexion.rs.next()) {
//
//                d = Connexion.rs.getDouble(1);
//                ch = Connexion.rs.getString(2);
//                //System.out.println("" + d);
//                //System.out.println("" + ch);
//
//                dataset.setValue(ch, d);//remplissage dataset
//            }
//
//        } catch (SQLException ex) {
//            System.out.println("...");
//        }
        graphe = ChartFactory.
                createPieChart("categorie de plat :", dataset,true ,true ,false);

        cp = new ChartPanel(graphe);
        this.add(cp);
    }


  /*  public static void main (String args[]) throws SQLException{
        StatCategorie pchart = new StatCategorie();
        pchart.setVisible(true);
        pchart.setSize(new Dimension(500, 500));
    }*/
    
    public  void affiche () throws SQLException{
        StatCategorie pchart = new StatCategorie();
        pchart.setVisible(true);
        pchart.setSize(new Dimension(500, 500));
}
}
